package com.aoip.telemetry.telemetry.entity.common;

import com.aoip.telemetry.telemetry.entity.enums.LogLevelEnum;
import com.aoip.telemetry.telemetry.entity.enums.LogTypeEnum;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author chenbai
 * @version 1.0
 * @date 2021/12/1 14:44
 */
@Data
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("t_logger_info")
@ApiModel(description = "日志信息表")
public class LogEntity implements Serializable {

    private static final long serialVersionUID = -3594484722225983320L;
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @ApiModelProperty("数据id")
    private Long id;

    @TableField(value = "st_code")
    @ApiModelProperty("测站编码")
    private String stCode;

    @TableField(value = "log_type")
    @ApiModelProperty("日志类型")
    private LogTypeEnum logType;

    @TableField(value = "logger_level")
    @ApiModelProperty("日志级别")
    private LogLevelEnum loggerLevel;

    @TableField(value = "execution_time")
    @ApiModelProperty("执行耗时")
    private long executionTime;

    @TableField(value = "original_text")
    @ApiModelProperty("原始报文")
    private String originalText;

    @TableField(value = "log_msg")
    @ApiModelProperty("日志完整信息")
    private String logMsg;

    @TableField(value = "create_time", fill = FieldFill.INSERT )
    @ApiModelProperty("日志创建时间，系统默认")
    private LocalDateTime createTime;

    public LogEntity(LogTypeEnum logType, LogLevelEnum loggerLevel, String logMsg) {
        this.logType = logType;
        this.loggerLevel = loggerLevel;
        this.logMsg = logMsg;
    }
    public LogEntity(LogTypeEnum logType,  String logMsg) {
        this(logType, LogLevelEnum.DEBUG, logMsg);
    }
    public LogEntity(LogTypeEnum logType) {
        this(logType, LogLevelEnum.DEBUG, "");
    }

}
